home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97b.txt
/
000099_icon-group-sender _Mon Oct 27 09:46:01 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
3KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by cheltenham.cs.arizona.edu (8.8.7/8.8.7) with SMTP id JAA00384
for <icon-group-addresses@cheltenham.CS.Arizona.EDU>; Mon, 27 Oct 1997 09:46:00 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA26110; Mon, 27 Oct 1997 09:46:00 -0700
To: icon-group@cs.arizona.edu
Date: Sat, 25 Oct 1997 17:49:51 +1000
From: Stuart.Robinson@anu.edu.au (Stuart Robinson)
Message-Id: <Stuart.Robinson-2510971749520001@asianstmg-229.anu.edu.au>
Organization: ANU
Sender: icon-group-request@cs.arizona.edu
Subject: one more question
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Again, thanks to everyone for their help with what is admittedly a pretty
trivial matter. It seems the key to my problem was tables, a structure
that I didn't understand until someone pointed out their necessity and I
read the appropriate section in _The Icon Programming Language_. (I
mention this fact only to prevent people from thinking that I just want
solutions handed to me on a silver platter)
Anyhow, I just have one more question:
Look at the program attached below (which is my modification of the
proposed solution sent to me by Steven Wampler). The problem with it is
this: I want to sort on the value being counted and not the counts
themselves. However, the sorting is fairly "dumb" and puts e.g. "4" after
e.g. "392" (looking at only the first digit). Is there a quick fix?
Cheers,
Stuart
############################################################################
#
# File: tabl_values.icn
# Subject: program written to do number count
# Author: Steven Wampler (w/ modifications by Stuart Robinson)
# Date: 25 October 1997
#
############################################################################
#
# The main revision consists of the if clause in the procedure
# countnums(), which now looks for lines with O's that had no
# referential index and therefore have no lookback value.
#
############################################################################
procedure main()
counts := sort( countnums(), 1 ) # HEREIN LIES THE PROBLEM!!!
every i := *counts to 1 by -1 do
{
write( counts[i][1] || "\t" || counts[i][2] )
}
end
procedure countnums()
numcount := table(0)
while line := read() do
line ?
{
if find( "no ref index" )
then numcount[ "NA" ] +:= 1
else
while tab( upto( &digits ) ) do
numcount[ tab( many( &digits ) ) ] +:= 1
}
return numcount
end
--
Stuart Robinson <Stuart.Robinson@nospam.anu.edu.au>
The Australian National University
*TO REPLY, REMOVE "nospam." FROM E-MAIL ADDRESS GIVEN ABOVE